package com.hxzy.controller;

import com.hxzy.feign.UserFeign;
import com.hxzy.pojo.Admin;
import com.hxzy.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/userfeign")
public class UserFeignController {
    @Autowired
    private UserFeign userFeign;

    @RequestMapping("/userAdd")
    public Result userAdd(@RequestBody Admin admin){
        Result result = userFeign.addAdmin(admin);
        return result;
    }

    @RequestMapping("userLogin")
    @PreAuthorize("#admin.name.equals('lhc')")
    public Result userLogin(@RequestBody Admin admin){
        Result login = userFeign.login(admin);
        return login;
    }
}
